package com.buba.springcloud.config;

import com.buba.loadbalancer.CustomLoadBalancerConfiguration;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 * @author 张宇飞
 * @Description:
 * @date 2021/8/917:16
 */
@Configuration
//@LoadBalancerClients(defaultConfiguration = {CustomLoadBalancerConfiguration.class}) //注入轮询规则
public class ConfigBean {
    /**
     * 把RestTemplate对象交给Spring管理
     * @return
     */
    @Bean
    @LoadBalanced
    public RestTemplate getRestTemplate(){

        return new RestTemplate();
    }
}
